#ifndef BOCALG_SM4_H
#define BOCALG_SM4_H
#include<string.h>
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include<basetsd.h>

typedef UINT32 uint32_t;
#else
#include<inttypes.h>
#endif
#define SM4_ENCRYPT 1
#define SM4_DECRYPT 0
#ifdef __cplusplus
extern "C" {
#endif


    typedef struct
    {
    int mode; 
    uint32_t sk[32];
    }
    sm4_context;

void sm4_init( sm4_context ctx );
void sm4_free( sm4_context ctx );

    void sm4_setkey_enc( sm4_context ctx, unsigned char key[16] );

    void sm4_setkey_dec( sm4_context ctx, unsigned char key[16] );

    int sm4_crypt_ecb( sm4_context ctx,
    int mode,
    int length,
    unsigned char input,
    unsigned char output);

    int sm4_crypt_cbc( sm4_context ctx,
    int mode,
    int length,
    unsigned char iv[16],
    unsigned char input,
    unsigned char output );

#ifdef __cplusplus
}
#endif
#endif 

